<template>
  <div class="permissions" v-loading="loading">
    <div class="permissions-first">管理员添加</div>
    <div class="permissions-second">
      <div class="top-list" v-for="(item, index) in 3" :key="index">
        <div class="list-title">
          {{
            index == 0
              ? "id名称"
              : index == 1
              ? "手机号码"
              : index == 2
              ? "id密码"
              : ""
          }}
        </div>
        <div class="list-input">
          <el-input
            v-if="index == 0"
            placeholder="请输入id名称"
            v-model="idName"
            clearable
          >
          </el-input>

          <el-input
            v-if="index == 1"
            placeholder="请输入手机号码"
            v-model="idPhone"
            clearable
          >
          </el-input>

          <el-input
            v-if="index == 2"
            :placeholder="idName == '' ? '请添加id密码' : '请重新设置id密码'"
            v-model="idPassword"
            clearable
          >
          </el-input>
        </div>
      </div>

      <!-- <div
        class="permissions-second-list"
        v-for="(item, index) in 3"
        :key="index"
      >
        <div class="permissions-second-list-title">
          {{
            index == 0
              ? "id名称"
              : index == 1
              ? "手机号码"
              : index == 2
              ? "id密码"
              : ""
          }}
        </div>
        <div class="permissions-second-list-input">
          <el-input
            v-if="index == 0"
            placeholder="请输入id名称"
            v-model="idName"
            clearable
          >
          </el-input>

          <el-input
            v-if="index == 1"
            placeholder="请输入手机号码"
            v-model="idPhone"
            clearable
          >
          </el-input>

          <el-input
            v-if="index == 2"
            :placeholder="idName == '' ? '请添加id密码' : '请重新设置id密码'"
            v-model="idPassword"
            clearable
          >
          </el-input>
        </div>
      </div> -->
    </div>

    <div class="permissions-thirdly">
      <div class="permissions-thirdly-title">职位描述</div>
      <div class="permissions-thirdly-textarea">
        <el-input
          type="textarea"
          placeholder="请输入职位描述（选填）"
          v-model="positionTextarea"
          maxlength=""
          show-word-limit
        >
        </el-input>
      </div>
    </div>

    <div class="permissions-fourthly">
      <div class="permissions-fourthly-title">权限设置</div>

      <div class="permissions-fourthly-block">
        <div class="fourthly-block-dealModule">
          <div class="dealModule-title">
            <el-checkbox
              :indeterminate="isIndeterminate"
              v-model="checkAll"
              @change="handleCheckAllChange"
              >全选
            </el-checkbox>
          </div>

          <div class="dealModule-display">
            <div
              class="dealModule-display-wallet"
              v-for="(item, index) in 4"
              :key="index"
            >
              <div class="wallet-place" v-if="index == 0">
                <el-checkbox
                  :indeterminate="homeIsIndeterminate"
                  v-model="homeCheckAll"
                  @change="homeCheckAllChange"
                  >首页模块</el-checkbox
                >
              </div>
              <div class="wallet-list" v-if="index == 0">
                <el-checkbox-group
                  v-model="homeCheckedCities"
                  @change="homeCheckedCitiesChange"
                >
                  <el-checkbox
                    v-for="(item, index) in homeList"
                    :key="index"
                    :label="item"
                  >
                    {{ item.title }}
                  </el-checkbox>
                </el-checkbox-group>
              </div>

              <div class="wallet-place" v-if="index == 1">
                <el-checkbox
                  :indeterminate="walletIsIndeterminate"
                  v-model="walletCheckAll"
                  @change="walletCheckAllChange"
                  >钱包管理模块</el-checkbox
                >
              </div>
              <div class="wallet-list" v-if="index == 1">
                <el-checkbox-group
                  v-model="walletCheckedCities"
                  @change="walletCheckedCitiesChange"
                >
                  <el-checkbox
                    v-for="(item, index) in ransactionList"
                    :key="index"
                    :label="item"
                  >
                    {{ item.title }}
                  </el-checkbox>
                </el-checkbox-group>
              </div>

              <div class="wallet-place" v-if="index == 2">
                <el-checkbox
                  :indeterminate="orderIsIndeterminate"
                  v-model="orderCheckAll"
                  @change="orderCheckAllChange"
                  >订单管理模块</el-checkbox
                >
              </div>
              <div class="wallet-list" v-if="index == 2">
                <el-checkbox-group
                  v-model="orderCheckedCities"
                  @change="orderCheckedCitiesChange"
                >
                  <el-checkbox
                    v-for="(item, index) in orderList"
                    :key="index"
                    :label="item"
                  >
                    {{ item.title }}
                  </el-checkbox>
                </el-checkbox-group>
              </div>

              <div class="wallet-place" v-if="index == 3">
                <el-checkbox
                  :indeterminate="merchantIsIndeterminate"
                  v-model="merchantCheckAll"
                  @change="merchantCheckAllChange"
                  >商户管理模块</el-checkbox
                >
              </div>
              <div class="wallet-list" v-if="index == 3">
                <el-checkbox-group
                  v-model="merchantCheckedCities"
                  @change="merchantCheckedCitiesChange"
                >
                  <el-checkbox
                    v-for="(item, index) in merchantList"
                    :key="index"
                    :label="item"
                  >
                    {{ item.title }}
                  </el-checkbox>
                </el-checkbox-group>
              </div>

              <!--      <div class="wallet-place" v-if="index == 4">
                  <el-checkbox
                    :indeterminate="auditIsIndeterminate"
                    v-model="auditCheckAll"
                    @change="auditCheckAllChange"
                    >审核管理模块</el-checkbox
                  >
                </div>
                <div class="wallet-list" v-if="index == 4">
                  <el-checkbox-group
                    v-model="auditCheckedCities"
                    @change="auditCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="(item, index) in auditList"
                      :key="index"
                      :label="item"
                    >
                      {{ item.title }}
                    </el-checkbox>
                  </el-checkbox-group>
                </div>
  
                <div class="wallet-place" v-if="index == 5">
                  <el-checkbox
                    :indeterminate="activityIsIndeterminate"
                    v-model="activityCheckAll"
                    @change="activityCheckAllChange"
                    >活动设置管理模块</el-checkbox
                  >
                </div>
                <div class="wallet-list" v-if="index == 5">
                  <el-checkbox-group
                    v-model="activityCheckedCities"
                    @change="activityCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="(item, index) in activityList"
                      :key="index"
                      :label="item"
                    >
                      {{ item.title }}
                    </el-checkbox>
                  </el-checkbox-group>
                </div>
  
                <div class="wallet-place" v-if="index == 6">
                  <el-checkbox
                    :indeterminate="marketingIsIndeterminate"
                    v-model="marketingCheckAll"
                    @change="marketingCheckAllChange"
                    >营销中心</el-checkbox
                  >
                </div>
                <div class="wallet-list" v-if="index == 6">
                  <el-checkbox-group
                    v-model="marketingCheckedCities"
                    @change="marketingCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="(item, index) in marketingList"
                      :key="index"
                      :label="item"
                    >
                      {{ item.title }}
                    </el-checkbox>
                  </el-checkbox-group>
                </div>
  
                <div class="wallet-place" v-if="index == 7">
                  <el-checkbox
                    :indeterminate="supplierIsIndeterminate"
                    v-model="supplierCheckAll"
                    @change="supplierCheckAllChange"
                    >供应商管理模块</el-checkbox
                  >
                </div>
                <div class="wallet-list" v-if="index == 7">
                  <el-checkbox-group
                    v-model="supplierCheckedCities"
                    @change="supplierCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="(item, index) in supplierList"
                      :key="index"
                      :label="item"
                    >
                      {{ item.title }}
                    </el-checkbox>
                  </el-checkbox-group>
                </div>
  
                <div class="wallet-place" v-if="index == 8">
                  <el-checkbox
                    :indeterminate="basicsIsIndeterminate"
                    v-model="basicsCheckAll"
                    @change="basicsCheckAllChange"
                    >基础设置模块</el-checkbox
                  >
                </div>
                <div class="wallet-list" v-if="index == 8">
                  <el-checkbox-group
                    v-model="basicsCheckedCities"
                    @change="basicsCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="(item, index) in basicsList"
                      :key="index"
                      :label="item"
                    >
                      {{ item.title }}
                    </el-checkbox>
                  </el-checkbox-group>
                </div>
  
                <div class="wallet-place" v-if="index == 9">
                  <el-checkbox
                    :indeterminate="commodityIsIndeterminate"
                    v-model="commodityCheckAll"
                    @change="commodityCheckAllChange"
                    >商品管理模块</el-checkbox
                  >
                </div>
                <div class="wallet-list" v-if="index == 9">
                  <el-checkbox-group
                    v-model="commodityCheckedCities"
                    @change="commodityCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="(item, index) in commodityList"
                      :key="index"
                      :label="item"
                    >
                      {{ item.title }}
                    </el-checkbox>
                  </el-checkbox-group>
                </div> -->
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="permissions-fifth" @click="submitRole">确定</div>
  </div>
</template>
  
  <script>
import { getmanagerIdList, postmanagerIdList } from "../../api/jurisdiction";

import Bus from "../../utils/bus"; // bus发送跳转关闭临时组件

// 权限  首页
const homeOptions = [
  {
    title: "首页页面展示",
    value: "HOME_SHOW",
  },
  {
    title: "首页功能",
    value: "HOME_FUNC",
  },
];

// 权限  第一模块  钱包管理模块
const walletOptions = [
  {
    title: "平台钱包页面展示",
    value: "WALLET_TERRACE_SHOW",
  },
  {
    title: "平台钱包功能",
    value: "WALLET_TERRACE_FUNC",
  },
  {
    title: "乡米网钱包页面展示",
    value: "WALLET_XIANGM_SHOW",
  },
  {
    title: "乡米网钱包功能",
    value: "WALLET_XIANGM_FUNC",
  },
  //------
  {
    title: "平台钱包功能-转账",
    value: "WALLET_TERRACE_TRANSFER_FUNC",
  },
  {
    title: "平台钱包功能-转平台",
    value: "WALLET_TERRACE_PLATFORM_FUNC",
  },
  {
    title: "平台钱包功能-转商户",
    value: "WALLET_TERRACE_TENANT_FUNC",
  },

];
//  权限  第二模块  订单管理模块
const orderOptions = [
  {
    title: "平台订单页面展示",
    value: "ORDER_TERRACE_SHOW",
  },
  {
    title: "平台订单功能",
    value: "ORDER_TERRACE_FUNC",
  },
  {
    title: "乡米网订单页面展示",
    value: "ORDER_XIANGM_SHOW",
  },
  {
    title: "乡米网订单功能",
    value: "ORDER_XIANGM_FUNC",
  },
];

//  权限  第三模块  商户管理模块
const merchantOptions = [
  {
    title: "商户列表页面展示",
    value: "MERCHANT_LIST_SHOW",
  },
  {
    title: "商户列表功能",
    value: "MERCHANT_LIST_FUNC",
  },
  {
    title: "商户订单页面展示",
    value: "MERCHANT_ORDER_SHOW",
  },
  {
    title: "商户订单功能",
    value: "MERCHANT_ORDER_FUNC",
  },
];

//  权限  第三模块  活动设置管理管理模块
// const activityOptions = [
//   {
//     title: "大转盘设置页面展示",
//     value: "WHEEL_SET_SHOW",
//   },
//   {
//     title: "大转盘设置功能",
//     value: "WHEEL_SET_FUNC",
//   },
//   {
//     title: "大转盘中奖明细页面展示",
//     value: "WHEEL_DETAIL_SHOW",
//   },
//   {
//     title: "大转盘中奖明细功能",
//     value: "WHEEL_DETAIL_FUNC",
//   },
//   {
//     title: "积分兑换红包设置页面展示",
//     value: "INTEGRAL_RED_SHOW",
//   },
//   {
//     title: "积分红包兑换设置功能",
//     value: "INTEGRAL_RED_FUNC",
//   },
//   {
//     title: "积分红包兑换明细页面展示",
//     value: "INTEGRAL_RED_DETAIL_SHOW",
//   },
//   {
//     title: "积分红包兑换明细功能",
//     value: "INTEGRAL_RED_DETAIL_FUNC",
//   },
//   {
//     title: "每日爆品页面展示",
//     value: "DAY_EXPLOSIVE_SHOW",
//   },
//   {
//     title: "每日爆品功能",
//     value: "DAY_EXPLOSIVE_FUNC",
//   },
//   {
//     title: "限时秒杀页面展示",
//     value: "TIME_SECKIL_SHOW",
//   },
//   {
//     title: "限时秒杀功能",
//     value: "TIME_SECKIL_FUNC",
//   },
// ];

export default {
  data() {
    return {
      // 用户名  id名称
      idName: "",
      // 昵称
      idnickName: "",
      // id手机号
      idPhone: "",
      // id密码
      idPassword: "",
      // 职位描述
      positionTextarea: "",
      // 当前管理员的id
      roleId: "",
      // 数组合并暂时缓存数组
      countArray: [],
      // 汇总所有页面数组
      roleCollectArray: [],
      // 进入存储数组权限设置
      roleCollectList: [],
      // 监听用户刷新
      loading: false,
      // 权限设置
      //************************* */
      // 权限设置第一模块 交易管理模块 总和 一键合并
      checkAll: false,
      checkedCities: [],
      cities: [],
      isIndeterminate: true,
      // 权限设置 首页
      homeCheckAll: false,
      homeCheckedCities: [],
      homeList: homeOptions,
      homeIsIndeterminate: true,
      // 权限设置第一模块 交易管理模块
      walletCheckAll: false,
      walletCheckedCities: [],
      ransactionList: walletOptions,
      walletIsIndeterminate: true,
      // 权限设置第二模块 用户管理权限
      orderCheckAll: false,
      orderCheckedCities: [],
      orderList: orderOptions,
      orderIsIndeterminate: true,
      // 权限设置第三模块 商户管理
      merchantCheckAll: false,
      merchantCheckedCities: [],
      merchantList: merchantOptions,
      merchantIsIndeterminate: true,

      // activityCheckAll: false,
      // activityCheckedCities: [],
      // activityList: activityOptions,
      // activityIsIndeterminate: true,
      // // 权限设置第四模块 营销中心
      // marketingCheckAll: false,
      // marketingCheckedCities: [],
      // marketingList: marketingOptions,
      // marketingIsIndeterminate: true,
      // // 权限设置第五模块 供应商管理模块
      // supplierCheckAll: false,
      // supplierCheckedCities: [],
      // supplierList: supplierOptions,
      // supplierIsIndeterminate: true,
      // // 权限设置第六模块 基础设置模块
      // basicsCheckAll: false,
      // basicsCheckedCities: [],
      // basicsList: basicsOptions,
      // basicsIsIndeterminate: true,
      // // 权限设置第七模块 商品管理模块
      // commodityCheckAll: false,
      // commodityCheckedCities: [],
      // commodityList: commodityOptions,
      // commodityIsIndeterminate: true,
      // // 权限设置第八模块 合伙人管理模块
      // partnerCheckAll: false,
      // partnerCheckedCities: [],
      // partnerList: partnerOptions,
      // partnerIsIndeterminate: true,
      // // 权限设置第九模块 合伙人管理模块
      // auditCheckAll: false,
      // auditCheckedCities: [],
      // auditList: auditOptions,
      // auditIsIndeterminate: true,
    };
  },
  created() {
    // 获取管理员id
    if (this.$route.query.id != undefined) {
      this.roleId = this.$route.query.id;
      this.loading = true;
      this.getmanagerIdListMet();
    }
  },
  methods: {
    // 获取管理员详情
    getmanagerIdListMet() {
      let params = this.roleId;

      getmanagerIdList(params).then((res) => {
        if (res.resultStatus == true) {
          console.log("接口返回", res);
          // 管理员id名称
          this.idName = res.resultData.userName;
          // 手机号
          this.idPhone = res.resultData.phone;
          // 昵称
          this.idnickName = res.resultData.nickname;
          // 职位描述
          this.positionTextarea = res.resultData.positionDesc;

          // 权限组查看
          this.roleCollectList =
            res.resultData.resource == null
              ? []
              : res.resultData.resource.split(";");

          this.loading = false;

          this.roleCollectClick();
        }
      });
    },

    // 权限设置 第一模块 全选
    handleCheckAllChange(val) {
      if (val == false) {
        this.homeCheckedCities = [];
        this.walletCheckedCities = [];
        this.orderCheckedCities = [];
        this.merchantCheckedCities = [];
        //   this.marketingCheckedCities = []
        //   this.supplierCheckedCities = []
        //   this.basicsCheckedCities = []
        //   this.commodityCheckedCities = []
        //   this.partnerCheckedCities = []
        //   this.auditCheckedCities = []

        this.isIndeterminate = true;

        this.homeCheckAll = false;
        this.walletCheckAll = false;
        this.orderCheckAll = false;
        this.merchantCheckAll = false;
        //   this.marketingCheckAll = false
        //   this.supplierCheckAll = false
        //   this.basicsCheckAll = false
        //   this.commodityCheckAll = false
        //   this.partnerCheckAll = false
        //   this.auditCheckAll = false

        this.homeIsIndeterminate = true;
        this.walletIsIndeterminate = true;
        this.orderIsIndeterminate = true;
        this.merchantIsIndeterminate = true;
        //   this.marketingIsIndeterminate = true
        //   this.supplierIsIndeterminate = true
        //   this.basicsIsIndeterminate = true
        //   this.commodityIsIndeterminate = true
        //   this.partnerIsIndeterminate = true
        //   this.auditIsIndeterminate = true
      } else {
        this.homeCheckedCities = homeOptions;
        this.walletCheckedCities = walletOptions;
        this.orderCheckedCities = orderOptions;
        this.merchantCheckedCities = merchantOptions;
        //   this.marketingCheckedCities = marketingOptions
        //   this.supplierCheckedCities = supplierOptions
        //   this.basicsCheckedCities = basicsOptions
        //   this.commodityCheckedCities = commodityOptions
        //   this.partnerCheckedCities = partnerOptions
        //   this.auditCheckedCities = auditOptions

        this.homeCheckAll = true;
        this.walletCheckAll = true;
        this.orderCheckAll = true;
        this.merchantCheckAll = true;
        //   this.marketingCheckAll = true
        //   this.supplierCheckAll = true
        //   this.basicsCheckAll = true
        //   this.commodityCheckAll = true
        //   this.partnerCheckAll = true
        //   this.auditCheckAll = true

        this.homeIsIndeterminate = false;
        this.walletIsIndeterminate = false;
        this.orderIsIndeterminate = false;
        this.merchantIsIndeterminate = false;
        //   this.marketingIsIndeterminate = false
        //   this.supplierIsIndeterminate = false
        //   this.basicsIsIndeterminate = false
        //   this.commodityIsIndeterminate = false
        //   this.partnerIsIndeterminate = false
        //   this.auditIsIndeterminate = false

        this.isIndeterminate = false;
        this.checkAll = true;
      }
    },

    // 设置一个方法进行调用判断  这三个值是否都是true
    dealAllBtn() {
      if (
        this.homeCheckAll == true &&
        this.walletCheckAll == true &&
        this.orderCheckAll == true &&
        this.merchantCheckAll == true
        //   this.marketingCheckAll == true &&
        //   this.supplierCheckAll == true &&
        //   this.basicsCheckAll == true &&
        //   this.commodityCheckAll == true
      ) {
        this.isIndeterminate = false;
        this.checkAll = true;
      } else {
        this.isIndeterminate = true;
        this.checkAll = false;
      }
    },

    // 权限设置 首页模块
    homeCheckAllChange(val) {
      this.homeCheckedCities = val ? homeOptions : [];
      this.homeIsIndeterminate = false;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },
    // 权限设置 第一模块 交易管理模块 单独选中
    homeCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.homeCheckAll = checkedCount === this.homeList.length;
      this.homeIsIndeterminate =
        checkedCount > 0 && checkedCount < this.homeList.length;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },

    // 权限设置 第一模块 交易管理模块 全选
    walletCheckAllChange(val) {
      this.walletCheckedCities = val ? walletOptions : [];
      this.walletIsIndeterminate = false;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },
    // 权限设置 第一模块 交易管理模块 单独选中
    walletCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.walletCheckAll = checkedCount === this.ransactionList.length;
      this.walletIsIndeterminate =
        checkedCount > 0 && checkedCount < this.ransactionList.length;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },

    // 权限设置 第二模块 用户管理权限 全选
    orderCheckAllChange(val) {
      this.orderCheckedCities = val ? orderOptions : [];
      this.orderIsIndeterminate = false;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },
    // 权限设置 第二模块 用户管理权限 单独选中
    orderCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.orderCheckAll = checkedCount === this.orderList.length;
      this.orderIsIndeterminate =
        checkedCount > 0 && checkedCount < this.orderList.length;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },

    // 权限设置 第三模块 活动设置管理 全选
    merchantCheckAllChange(val) {
      this.merchantCheckedCities = val ? merchantOptions : [];
      this.merchantIsIndeterminate = false;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },
    // 权限设置 第三模块 活动设置管理 单独选中
    merchantCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.merchantCheckAll = checkedCount === this.merchantList.length;
      this.merchantIsIndeterminate =
        checkedCount > 0 && checkedCount < this.merchantList.length;
      // 每次点击都要进行判断
      this.dealAllBtn();
    },

    //   // 权限设置 第四模块 营销中心 全选
    //   marketingCheckAllChange(val) {
    //     this.marketingCheckedCities = val ? marketingOptions : []
    //     this.marketingIsIndeterminate = false
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },
    //   // 权限设置 第四模块 营销中心 单独选中
    //   marketingCheckedCitiesChange(value) {
    //     let checkedCount = value.length
    //     this.marketingCheckAll = checkedCount === this.marketingList.length
    //     this.marketingIsIndeterminate =
    //       checkedCount > 0 && checkedCount < this.marketingList.length
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },

    //   // 权限设置 第五模块 营销中心 全选
    //   supplierCheckAllChange(val) {
    //     this.supplierCheckedCities = val ? supplierOptions : []
    //     this.supplierIsIndeterminate = false
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },
    //   // 权限设置 第五模块 营销中心 单独选中
    //   supplierCheckedCitiesChange(value) {
    //     let checkedCount = value.length
    //     this.supplierCheckAll = checkedCount === this.supplierList.length
    //     this.supplierIsIndeterminate =
    //       checkedCount > 0 && checkedCount < this.supplierList.length
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },

    //   // 权限设置 第六模块 基础设置模块 全选
    //   basicsCheckAllChange(val) {
    //     this.basicsCheckedCities = val ? basicsOptions : []
    //     this.basicsIsIndeterminate = false
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },
    //   // 权限设置 第六模块 基础设置模块 单独选中
    //   basicsCheckedCitiesChange(value) {
    //     let checkedCount = value.length
    //     this.basicsCheckAll = checkedCount === this.basicsList.length
    //     this.basicsIsIndeterminate =
    //       checkedCount > 0 && checkedCount < this.basicsList.length
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },

    //   // 权限设置 第七模块 商品管理模块 全选
    //   commodityCheckAllChange(val) {
    //     this.commodityCheckedCities = val ? commodityOptions : []
    //     this.commodityIsIndeterminate = false
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },
    //   // 权限设置 第七模块 商品管理模块 单独选中
    //   commodityCheckedCitiesChange(value) {
    //     let checkedCount = value.length
    //     this.commodityCheckAll = checkedCount === this.commodityList.length
    //     this.commodityIsIndeterminate =
    //       checkedCount > 0 && checkedCount < this.commodityList.length
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },

    //   // 权限设置 第八模块 合伙人管理模块 全选
    //   partnerCheckAllChange(val) {
    //     this.partnerCheckedCities = val ? partnerOptions : []
    //     this.partnerIsIndeterminate = false
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },
    //   // 权限设置 第八模块 合伙人管理模块 单独选中
    //   partnerCheckedCitiesChange(value) {
    //     let checkedCount = value.length
    //     this.partnerCheckAll = checkedCount === this.partnerList.length
    //     this.partnerIsIndeterminate =
    //       checkedCount > 0 && checkedCount < this.partnerList.length
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },

    //   // 权限设置 第八模块 合伙人管理模块 全选
    //   auditCheckAllChange(val) {
    //     this.auditCheckedCities = val ? auditOptions : []
    //     this.auditIsIndeterminate = false
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },
    //   // 权限设置 第九模块 合伙人管理模块 单独选中
    //   auditCheckedCitiesChange(value) {
    //     let checkedCount = value.length
    //     this.auditCheckAll = checkedCount === this.auditList.length
    //     this.auditIsIndeterminate =
    //       checkedCount > 0 && checkedCount < this.auditList.length
    //     // 每次点击都要进行判断
    //     this.dealAllBtn()
    //   },

    /*****************汇总算法*************** */
    roleCollectClick() {
      this.roleCollectArray = walletOptions.concat(
        orderOptions,
        homeOptions,
        merchantOptions
        //   marketingOptions,
        //   supplierOptions,
        //   basicsOptions,
        //   commodityOptions,
        //   partnerOptions,
        //   auditOptions,
        //
      );

      console.log("进入后默认汇总数组", this.roleCollectArray);

      if (this.roleCollectArray.length == this.roleCollectList.length) {
        // 数组长度一致则直接默认全部勾选
        this.handleCheckAllChange(true);
      } else {
        // 数组长度不一致
        this.handleCheckAllChange(false);
        // 通过接口返回的数组进行
        this.roleCollectList.forEach((item, index) => {
          //   console.log('总数据', item)

          // 判断首页模块中是否全部存在
          for (let i = 0; i < homeOptions.length; i++) {
            if (item == homeOptions[i].value) {
              this.homeCheckedCities.push(homeOptions[i]);
              if (this.homeCheckedCities.length == homeOptions.length) {
                this.homeCheckAll = true;
                this.homeIsIndeterminate = false;
              }
            }
          }

          // 判断第一模块中是否全部存在
          for (let i = 0; i < walletOptions.length; i++) {
            if (item == walletOptions[i].value) {
              this.walletCheckedCities.push(walletOptions[i]);
              if (this.walletCheckedCities.length == walletOptions.length) {
                this.walletCheckAll = true;
                this.walletIsIndeterminate = false;
              }
            }
          }

          // 判断第二模块中是否全部存在
          for (let i = 0; i < orderOptions.length; i++) {
            if (item == orderOptions[i].value) {
              this.orderCheckedCities.push(orderOptions[i]);
              if (this.orderCheckedCities.length == orderOptions.length) {
                this.orderCheckAll = true;
                this.orderIsIndeterminate = false;
              }
            }
          }

          // 判断第三模块中是否全部存在
          for (let i = 0; i < merchantOptions.length; i++) {
            if (item == merchantOptions[i].value) {
              this.merchantCheckedCities.push(merchantOptions[i]);

              if (this.merchantCheckedCities.length == merchantOptions.length) {
                this.merchantCheckAll = true;
                this.merchantIsIndeterminate = false;
              }
            }
          }

          // // 判断第四模块中是否全部存在
          // for (let i = 0; i < marketingOptions.length; i++) {
          //   if (item == marketingOptions[i].value) {
          //     this.marketingCheckedCities.push(marketingOptions[i])

          //     if (
          //       this.marketingCheckedCities.length == marketingOptions.length
          //     ) {
          //       this.marketingCheckAll = true
          //       this.marketingIsIndeterminate = false
          //     }
          //   }
          // }

          // // 判断第五模块中是否全部存在
          // for (let i = 0; i < supplierOptions.length; i++) {
          //   if (item == supplierOptions[i].value) {
          //     this.supplierCheckedCities.push(supplierOptions[i])

          //     if (this.supplierCheckedCities.length == supplierOptions.length) {
          //       this.supplierCheckAll = true
          //       this.supplierIsIndeterminate = false
          //     }
          //   }
          // }

          // // 判断第六模块中是否全部存在
          // for (let i = 0; i < basicsOptions.length; i++) {
          //   if (item == basicsOptions[i].value) {
          //     this.basicsCheckedCities.push(basicsOptions[i])

          //     if (this.basicsCheckedCities.length == basicsOptions.length) {
          //       this.basicsCheckAll = true
          //       this.basicsIsIndeterminate = false
          //     }
          //   }
          // }

          // // 判断第七模块中是否全部存在
          // for (let i = 0; i < commodityOptions.length; i++) {
          //   if (item == commodityOptions[i].value) {
          //     this.commodityCheckedCities.push(commodityOptions[i])

          //     if (
          //       this.commodityCheckedCities.length == commodityOptions.length
          //     ) {
          //       this.commodityCheckAll = true
          //       this.commodityIsIndeterminate = false
          //     }
          //   }
          // }

          // // 判断第八模块中是否全部存在
          // for (let i = 0; i < partnerOptions.length; i++) {
          //   if (item == partnerOptions[i].value) {
          //     this.partnerCheckedCities.push(partnerOptions[i])

          //     if (this.partnerCheckedCities.length == partnerOptions.length) {
          //       this.partnerCheckAll = true
          //       this.partnerIsIndeterminate = false
          //     }
          //   }
          // }

          // // 判断第九模块中是否全部存在
          // for (let i = 0; i < auditOptions.length; i++) {
          //   if (item == auditOptions[i].value) {
          //     this.auditCheckedCities.push(auditOptions[i])

          //     if (this.auditCheckedCities.length == auditOptions.length) {
          //       this.auditCheckAll = true
          //       this.auditIsIndeterminate = false
          //     }
          //   }
          // }
        });
      }
    },

    /*---------------权限提交确定------------------------ */
    submitRole() {
      // 首页模块
      console.log("点击确定", this.homeCheckedCities);
      // 交易模块
      console.log("点击确定", this.walletCheckedCities);
      // 用户管理权限
      console.log("点击确定", this.orderCheckedCities);
      // 活动设置管理
      console.log("点击确定", this.merchantCheckedCities);
      // // 营销中心
      // console.log('点击确定', this.marketingCheckedCities)
      // // 供应商管理模块
      // console.log('点击确定', this.supplierCheckedCities)
      // // 基础设置模块
      // console.log('点击确定', this.basicsCheckedCities)
      // // 商品管理模块
      // console.log('点击确定', this.commodityCheckedCities)
      // // 合伙人管理模块
      // console.log('点击确定', this.partnerCheckedCities)
      // // 审核管理模块
      // console.log('点击确定', this.auditCheckedCities)

      // 第一步合并数组进行排序分配

      this.countArray = this.walletCheckedCities.concat(
        this.orderCheckedCities,
        this.homeCheckedCities,
        this.merchantCheckedCities
        //   this.marketingCheckedCities,
        //   this.supplierCheckedCities,
        //   this.basicsCheckedCities,
        //   this.commodityCheckedCities,
        //   this.partnerCheckedCities,
        //   this.auditCheckedCities,
        //
      );

      console.log("是否合并成一个数组", this.countArray);
      let commodityIds = this.countArray
        .map((item) => {
          return item.value;
        })
        .join(";");

      let params = {
        id: this.roleId, // 管理员id
        userName: this.idName, // 用户名 id名称
        nickname: this.idnickName, // 昵称
        phone: this.idPhone, //  手机号码
        position: "", //  职位 暂不显示
        positionDesc: this.positionTextarea, // 职位描述
        resource: commodityIds, // 资源组
        password: this.idPassword, // 密码 如果是修改,则可传空，代表不修改密码，若输入，则视为修改密码
      };

      console.log("勾选所有的权限", params);
      postmanagerIdList(params).then((res) => {
        if (res.resultStatus == true) {
          this.$message({
            message: this.roleId == "" ? "新增成功！" : "修改成功！",
            type: "success",
            duration: 2000,
          });

          Bus.$emit("detele", "jurisdictionRoleAdd");
        }
      });
    },
  },
};
</script>
  
  <style lang="less" scoped>
/deep/ .el-input__inner:focus {
  border-color: rgba(217, 217, 217, 1);
}

/deep/ .el-textarea__inner:focus {
  border-color: rgba(217, 217, 217, 1);
}

/deep/ .el-select .el-input.is-focus .el-input__inner {
  border-color: rgba(255, 255, 255, 0);
}

.permissions {
  border-radius: 10px;

  .permissions-first {
    font-size: 14px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 600;
    color: #222222;
  }

  .permissions-second {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 10px;
    .top-list {
      display: flex;
      align-items: center;
      margin-right: 12px;

      .list-title {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 14px;
        color: #757575;
        margin-right: 12px;
      }

      .list-input {
        /deep/ .el-input__inner {
          width: 174px;
          height: 38px;
          background: #ffffff;
          border-radius: 4px;
        }
      }
    }

    .top-list:last-child {
      margin-right: 0;
    }
  }

  .permissions-thirdly {
    margin-top: 22px;

    .permissions-thirdly-title {
      font-size: 12px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
    }

    .permissions-thirdly-textarea {
      margin-top: 4px;
      width: 606px;
      height: 110px;
      background: #ffffff;
      border-radius: 5px;

      /deep/ .el-textarea {
        height: 100%;
        cursor: pointer;
      }

      /deep/ .el-textarea__inner {
        height: 100%;
        padding: 10px 10px 20px;
      }

      /deep/ .el-textarea .el-textarea__inner {
        // 然后找到对应的类名，在这里将拉伸去掉即可
        resize: none;
      }
    }
  }

  .permissions-fourthly {
    margin-top: 21px;
    border-top: 1px solid #edeff7;
    padding-top: 24px;
    box-sizing: border-box;

    .permissions-fourthly-title {
      font-size: 12px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
    }

    .permissions-fourthly-block {
      border: 1px solid #e8e8e8;
      margin-top: 4px;
      min-height: 250px;
      padding: 19px 17px;
      box-sizing: border-box;

      .fourthly-block-dealModule {
        .dealModule-title {
          /deep/ .el-checkbox__label {
            font-size: 12px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #333333;
          }
        }

        .dealModule-display {
          margin-top: 11px;

          .dealModule-display-wallet {
            width: 100%;
            display: flex;
            border: 1px solid #e8e8e8;

            .wallet-place {
              background: #fafafa;
              display: flex;
              align-items: center;
              justify-content: center;

              /deep/ .el-checkbox {
                width: 180px;
                margin-right: 8px;
                display: flex;
                align-items: center;
                background: #fafafa;
                padding-left: 16px;
              }
            }

            .wallet-list {
              display: flex;

              /deep/ .el-checkbox {
                height: 46px;
                margin-right: 8px;
                display: flex;
                padding-left: 16px;
                align-items: center;
              }

              /deep/ .el-checkbox:last-child {
                margin-right: 0;
              }

              /deep/ .el-checkbox-group {
                display: flex;
                flex-wrap: wrap;
              }
            }
          }
        }
      }
    }
  }

  .permissions-fifth {
    width: 88px;
    height: 36px;
    background: linear-gradient(135deg, #36c53d 0%, #3fd747 100%);
    border-radius: 10px;
    text-align: center;
    line-height: 36px;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #ffffff;
    margin-top: 23px;
    cursor: pointer;
  }
}
</style>
  